package xw.qxypt.modules.api.controller;


import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import xw.qxypt.common.utils.R;
import xw.qxypt.modules.api.service.ApiService;
import xw.qxypt.modules.baseinfo.entity.LhpDataRoadDetectorEntity;
import xw.qxypt.modules.baseinfo.entity.LhpDataVisibilityEntity;
import xw.qxypt.modules.baseinfo.entity.LhpDataWeatherStationEntity;
import xw.qxypt.modules.baseinfo.entity.LhpInstallationPointEntity;
import xw.qxypt.modules.baseinfo.service.LhpDataRoadDetectorService;
import xw.qxypt.modules.baseinfo.service.LhpDataVisibilityService;
import xw.qxypt.modules.baseinfo.service.LhpDataWeatherStationService;
import xw.qxypt.modules.baseinfo.service.LhpInstallationPointService;

import java.text.SimpleDateFormat;
import java.util.*;


@Controller
@RequestMapping("/api")
public class ApiController {
    @Autowired
    private ApiService apiService;

    //根据安装点查询数据
    @ResponseBody
    @RequestMapping("/getDataByPointId")
    public R getDataByPointId(String key,String pointId){
        if("63aae6fefeab4cedb98bc0e025ecb5e5".equals(key) && pointId!=null && !"".equals(pointId)){

            JSONObject object =apiService.getDataByPointId(pointId);

            return R.ok().put("resultData",object);
        }else {
            return R.error();
        }
    }

    //根据安装点查询数据
    @ResponseBody
    @RequestMapping("/getDataAll")
    public R getDataAll(String key){
        if("63aae6fefeab4cedb98bc0e025ecb5e5".equals(key)){

            Map<String,JSONObject> dataMap=apiService.getDataAll();

            return R.ok().put("resultData",dataMap.values());
        }else {
            return R.error();
        }
    }

}


